import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@layout'

export const constantRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    hidden: true,
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import(/* webpackChunkName: "chunk-base" */ '@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard', affix: true, noCache: true }
      }
    ]
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import(/* webpackChunkName: "chunk-base" */ '@/views/redirect/index')
      }
    ]
  },
  {
    path: '*',
    name: '404',
    component: () => import(/* webpackChunkName: "chunk-base" */ '@/views/404'),
    hidden: true
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "chunk-base" */ '@layout/login/Login1'),
    hidden: true
  },
  // 新系统菜单设置
  {
    path: '/',
    component: Layout,
    hidden: true,
    meta: { title: '新系统设置', icon: 'dashboard' },
    children: [
      {
        path: 'menu',
        component: Layout,
        name: 'menu',
        component: () => import(/* webpackChunkName: "menu" */ '@/views/system/menu/index'),
        meta: { title: '菜单管理', icon: 'dashboard' }
      },
      {
        path: 'role',
        component: Layout,
        name: 'role',
        component: () => import(/* webpackChunkName: "role" */ '@/views/system/role/index'),
        meta: { title: '角色管理', icon: 'dashboard' }
      },
      {
        path: 'api',
        component: Layout,
        name: 'api',
        component: () => import(/* webpackChunkName: "api" */ '@/views/system/api-set/index'),
        meta: { title: 'api管理', icon: 'dashboard' }
      },
      {
        path: 'user',
        component: Layout,
        name: 'user',
        component: () => import(/* webpackChunkName: "user" */ '@/views/system/user/index'),
        meta: { title: '用户管理', icon: 'dashboard' }
      },
      {
        path: 'organization',
        component: Layout,
        name: 'organization',
        component: () => import(/* webpackChunkName: "organization" */ '@/views/system/organization/index'),
        meta: { title: '机构管理', icon: 'dashboard' }
      },
      {
        path: 'holiday',
        component: Layout,
        name: 'holiday',
        component: () => import(/* webpackChunkName: "organization" */ '@/views/system/holiday/index'),
        meta: { title: '假期管理', icon: 'dashboard' }
      }

    ]
  },
  // 审批设置页面
  {
    path: '/date-limit',
    component: Layout,
    hidden: true,
    name: '审批时间管理',
    meta: { title: '审批时间管理', icon: 'dashboard' },
    children: [
      {
        path: 'opera',
        name: 'opera',
        component: Layout,
        component: () => import(/* webpackChunkName: "date-limit" */ '@/views/date-limit/opera'),
        meta: { title: '运维项目设置', icon: 'dashboard' }
      },
      {
        component: Layout,
        name: 'block',
        path: 'block',
        component: () => import(/* webpackChunkName: "date-limit" */ '@/views/date-limit/block/index'),
        meta: { title: '拦标价设置', icon: 'dashboard' }
      }

    ]
  },
  // 单位信息页面
  {
    path: '/sysUnit',
    component: Layout,
    hidden: true,
    name: '单位设置',
    meta: { title: '单位设置', icon: 'dashboard' },
    children: [
      {
        path: 'unit',
        name: 'unit',
        component: Layout,
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/sys-unit/unit'),
        meta: { title: '单位信息', icon: 'dashboard' }
      },
      {
        component: Layout,
        name: 'account',
        path: 'account',
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/sys-unit/account/index'),
        meta: { title: '账号设置', icon: 'dashboard' }
      },
      {
        component: Layout,
        name: 'password',
        path: 'password',
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/sys-unit/account/up'),
        meta: { title: '修改密码', icon: 'dashboard' }
      }
    ]
  },
  // 工单管理
  {
    path: '/workorder',
    component: Layout,
    hidden: true,
    name: '工单管理',
    meta: { title: '工单管理', icon: 'dashboard' },
    children: [
      {
        path: 'apply',
        name: 'apply',
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/workorder/index'),
        meta: { title: '需求单位', icon: 'dashboard' }
      },
      {
        path: 'apply2',
        name: 'apply2',
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/workorder/index2'),
        meta: { title: '保障部', icon: 'dashboard' }
      },
      {
        path: 'apply3',
        name: 'apply3',
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/workorder/index3'),
        meta: { title: '技术部', icon: 'dashboard' }
      },
      {
        path: 'apply4',
        name: 'apply4',
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/workorder/index4'),
        meta: { title: '运维总集', icon: 'dashboard' }
      },
      {
        path: 'audit',
        name: 'audit',
        component: () => import(/* webpackChunkName: "sysunit" */ '@/views/workorder/audit'),
        meta: { title: '已办列表', icon: 'dashboard' }
      }
    ]
  },
  // 历史查询页面
  {
    path: '/history',
    component: Layout,
    hidden: true,
    meta: { title: '运维项目查询列表', icon: 'dashboard' },
    children: [
      // 未上报到咨询机构的运维项目
      {
        path: 'block',
        component: Layout,
        name: 'historyBlock',
        component: () => import(/* webpackChunkName: "history" */ '@/views/past-project/block'),
        meta: { title: '历史申请项目', icon: 'dashboard' }
      },
      // 本单位审核过的历史运维项目
      {
        path: 'verify',
        component: Layout,
        name: 'verify',
        component: () => import(/* webpackChunkName: "history" */ '@/views/past-project/input/verify'),
        meta: { title: '历史审核项目', icon: 'dashboard' }
      },
      // 未上报到咨询机构的运维项目
      {
        path: 'inconformity',
        component: Layout,
        name: 'inconformity',
        component: () => import(/* webpackChunkName: "history" */ '@/views/past-project/input/apply'),
        meta: { title: '申请未提交项目', icon: 'dashboard' }
      }
    ]
  },
  // 项目申报页面
  {
    path: '/input-info',
    component: Layout,
    hidden: true,
    meta: { title: '运维项目设置', icon: 'dashboard' },
    children: [
      {
        path: 'usual/wait',
        component: Layout,
        name: 'usualWait',
        component: () => import(/* webpackChunkName: "input-info" */ '@/views/input/usual/wait/index'),
        meta: { title: '新增项目', icon: 'dashboard' }
      },
      {
        path: 'usual/reject',
        component: Layout,
        name: 'usualReject',
        component: () => import(/* webpackChunkName: "input-info" */ '@/views/input/usual/reject/index'),
        meta: { title: '被驳回项目', icon: 'dashboard' }
      },
      {
        path: 'usual/submit',
        component: Layout,
        name: 'usualSubmit',
        component: () => import(/* webpackChunkName: "input-info" */ '@/views/input/usual/submit/index'),
        meta: { title: '已上报项目', icon: 'dashboard' }
      }, {
        path: 'usual/requirement',
        component: Layout,
        name: 'usualRequirement',
        component: () => import(/* webpackChunkName: "input-info" */ '@/views/input/usual/requirement/index'),
        meta: { title: '需求确认书', icon: 'dashboard' }
      }
    ]
  },
  // 运维项目审核
  {
    path: '/verify',
    component: Layout,
    hidden: true,
    meta: { title: '运维项目审核', icon: 'dashboard' },
    children: [
      // 本单位审核
      {
        path: 'unit',
        component: Layout,
        name: 'unitIndex',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/unit/index'),
        meta: { title: '本单位审核', icon: 'dashboard' }
      },
      {
        path: 'unit/contract',
        component: Layout,
        name: 'unitContract',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/unit/contract'),
        meta: { title: '合同信息', icon: 'dashboard' }
      },
      {
        path: 'unit/it',
        component: Layout,
        name: 'unitIt',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/unit/it'),
        meta: { title: '运维服务和资金需求', icon: 'dashboard' }
      },
      // 保障部门
      {
        path: 'ensure/wait',
        component: Layout,
        name: 'ensureWait',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/ensure/wait'),
        meta: { title: '保障部门待办项目', icon: 'dashboard' }
      },
      {
        path: 'ensure/reject',
        component: Layout,
        name: 'ensureReject',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/ensure/reject'),
        meta: { title: '已驳回项目', icon: 'dashboard' }
      },
      {
        path: 'ensure/submit',
        component: Layout,
        name: 'ensureSubmit',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/ensure/submit'),
        meta: { title: '已提报项目', icon: 'dashboard' }
      },
      // 内设部门
      {
        path: 'inside/wait',
        component: Layout,
        name: 'insideWait',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/inside/wait'),
        meta: { title: '待办项目', icon: 'dashboard' }
      },
      {
        path: 'inside/reject',
        component: Layout,
        name: 'insideReject',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/inside/reject'),
        meta: { title: '已驳回项目', icon: 'dashboard' }
      },
      {
        path: 'inside/submit',
        component: Layout,
        name: 'insideSubmit',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/inside/submit'),
        meta: { title: '已提报项目', icon: 'dashboard' }
      },
      // 咨询机构
      {
        path: 'third/wait',
        component: Layout,
        name: 'thirdWait',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/third/wait'),
        meta: { title: '待办项目', icon: 'dashboard' }
      },
      {
        path: 'third/reject',
        component: Layout,
        name: 'thirdReject',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/third/reject'),
        meta: { title: '已驳回项目', icon: 'dashboard' }
      },
      {
        path: 'third/submit',
        component: Layout,
        name: 'thirdSubmit',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/third/submit'),
        meta: { title: '已提报项目', icon: 'dashboard' }
      },
      {
        path: 'third/requirement',
        component: Layout,
        name: 'thirdRequirement',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/third/requirement'),
        meta: { title: '需求确认书', icon: 'dashboard' }
      },
      {
        path: 'requirement',
        component: Layout,
        name: 'dzzwRequirement',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/requirement'),
        meta: { title: '需求确认书', icon: 'dashboard' }
      },
      // 电子政务部
      // 初审
      {
        path: 'gov/first/wait',
        component: Layout,
        name: 'firstWait',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/gov/first/wait'),
        meta: { title: '待处理项目', icon: 'dashboard' }
      },
      {
        path: 'gov/first/reject',
        component: Layout,
        name: 'firstReject',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/gov/first/reject'),
        meta: { title: '已驳回项目', icon: 'dashboard' }
      },
      {
        path: 'gov/first/submit',
        component: Layout,
        name: 'firstSubmit',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/gov/first/submit'),
        meta: { title: '已提报项目（咨询机构）', icon: 'dashboard' }
      },
      {
        path: 'gov/first/thirdReject',
        component: Layout,
        name: 'firstThirdReject',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/gov/first/third-reject'),
        meta: { title: '咨询机构驳回项目', icon: 'dashboard' }
      },
      // 复审
      {
        path: 'gov/second/wait',
        component: Layout,
        name: 'secondWait',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/gov/second/wait'),
        meta: { title: '待处理项目', icon: 'dashboard' }
      },
      {
        path: 'gov/second/reject',
        component: Layout,
        name: 'secondReject',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/gov/second/reject'),
        meta: { title: '被驳回项目', icon: 'dashboard' }
      },
      {
        path: 'gov/second/submit',
        component: Layout,
        name: 'secondSubmit',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/gov/second/submit'),
        meta: { title: '已提报项目', icon: 'dashboard' }
      },
      // 上传审核报告
      {
        path: 'gov/report',
        component: Layout,
        name: '运维项目审核报告',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/report/index'),
        meta: { title: '运维项目审核报告', icon: 'dashboard' }
      },
      // 项目审核分组
      {
        path: 'gov/pick',
        component: Layout,
        name: 'govPick',
        component: () => import(/* webpackChunkName: "verify" */ '@/views/verify/pick'),
        meta: { title: '项目审核分组', icon: 'dashboard' }
      }
    ]
  },
  // 拦标价审核
  {
    path: '/blockprice',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'ensure/index',
        name: 'ensureIndex',
        component: () => import(/* webpackChunkName: "blockprice" */'@/views/bid/ensure/index'),
        meta: { title: '运维项目打包', icon: 'dashboard' }
      },
      {
        path: 'gov/index',
        name: 'govIndex',
        component: () => import(/* webpackChunkName: "blockprice" */'@/views/bid/gov/index'),
        meta: { title: '各部门项目审核', icon: 'dashboard' }
      },
      {
        path: 'repack/index',
        name: 'repackIndex',
        component: () => import(/* webpackChunkName: "blockprice" */'@/views/bid/repack/no-finish'),
        meta: { title: '整合项目待办', icon: 'dashboard' }
      },
      {
        path: 'repack/finish',
        name: 'repackFinish',
        component: () => import(/* webpackChunkName: "blockprice" */'@/views/bid/repack/finish'),
        meta: { title: '整合项目已办', icon: 'dashboard' }
      },
      {
        path: 'third/index',
        name: 'thirdIndex',
        component: () => import(/* webpackChunkName: "blockprice" */'@/views/bid/third/index'),
        meta: { title: '咨询机构拦标价审核', icon: 'dashboard' }
      },
      {
        path: 'choose/index',
        name: 'chooseIndex',
        component: () => import(/* webpackChunkName: "blockprice" */'@/views/bid/choice/index'),
        meta: { title: '审定终审报告', icon: 'dashboard' }
      }
    ]
  },
  // 大屏数据展示模块
  {
    path: '/show',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'gov',
        name: 'showGov',
        component: () => import('@/views/shows/gov'),
        meta: { title: '数据展示', icon: 'dashboard' }
      },
      {
        path: 'count',
        name: 'showCount',
        component: () => import('@/views/shows/count'),
        meta: { title: '数据统计', icon: 'dashboard' }
      }
      ,
      {
        path: 'newcount',
        name: 'showNewCount',
        component: () => import('@/views/shows/newcount/input/verify'),
        meta: { title: '新数据统计', icon: 'dashboard' }
      }
    ]
  },
  // 测试模块
  {
    path: '/cs',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'drag',
        name: 'cs',
        component: () => import('@/views/cs/index.vue'),
        meta: { title: '测试', icon: 'dashboard' }
      }
      // {
      //   path: 'line',
      //   name: 'cs',
      //   component: () => import('@/views/cs/line'),
      //   meta: { title: '测试', icon: 'dashboard' }
      // }
    ]
  }
]

export const constantRouterComponents = {
  layout: Layout
}

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router

/*
属性	详解
path	路径
name	命名路由
component	命名视图组件
components	命名视图组件
redirect	重定向路径
alias	别名
children	嵌套路由
meta	路由元信息 使用$route.meta.属性可以获取
caseSensitive	匹配规则是否大小写敏感？(默认值：false)
pathToRegexpOptions	编译正则的选项
*/
